<?php

require_once "vo/Book.php";
require_once "tech/DBManager.php";


class BookService
{
    /**
     * Get a list of books
     * @returns An Array of Book
     */
    function getAllBooks()
    {
        $books=DBManager::getInstance()->query("select * from book");
        $allBooks = array();
       for($i = 0; $i < sizeof($books); $i++){
       		$b = new Book();
       		$b->id=$books[$i]["id"];
       		$b->title=$books[$i]["title"];
       		$b->author=$books[$i]["author"];
       		$b->ISBN=$books[$i]["ISBN"];
       		$b->description=$books[$i]["description"];
       		$allBooks[]=$b;
       }
       
       return $allBooks;
    }
}

?>
